// const HardSourceWebpackPlugin = require("hard-source-webpack-plugin");
module.exports = {
  publicPath: "./",
  devServer: {
    open: true,
    hot: true,
    host: "127.0.0.1",
    port: 9999,
    proxy: {
      "/const": {
        // target: "http://172.16.20.89:19095", //hl
        target: "http://59.110.150.141:19093", //hl
        // target: "http://192.168.32.49:19093", //杨博
        // target: "http://192.168.32.21:19093", //丰铭
        // target: "http://192.168.31.204:9093",
        // target: "http://192.168.31.175:9093",
        // target: "http://192.168.31.8:9093",
        ws: false,
        changeOrigin: false,
        pathRewrite: {
          "^/const": "",
        },
      },
      // 数据引接服务
      "/api": {
        target: "http://123.57.194.39:9005", //杨博
        // target: "http://192.168.31.120:9093",
        changeOrigin: true,
        pathRewrite: {
          "^/api/": "",
        },
      },
      // 态势信息
      "/demo": {
        target: "http://192.168.31.169:9992/demo",
        // target: "http://192.168.31.80:10021",
        // target: "http://192.168.31.169:10021",
        // target: "http://192.168.31.120:9093/demo",
        ws: false,
        changeOrigin: true,
        pathRewrite: {
          "^/demo": "",
        },
      },
    },
  },
  configureWebpack: {
    devtool:
      process.env.NODE_ENV === "production"
        ? false
        : "cheap-module-eval-source-map",
    // plugins: [new HardSourceWebpackPlugin()],
  },

  chainWebpack: (config) => {
    const oneOfsMap = config.module.rule("scss").oneOfs.store;
    oneOfsMap.forEach((item) => {
      item
        .use("sass-resources-loader")
        .loader("sass-resources-loader")
        .options({
          resources: "./src/assets/scss/index.scss",
        })
        .end();
      item
        .use("sass-loader")
        .loader("fast-sass-loader")
        .options({
          implementation: require("node-sass"),
        })
        .end();
    });
  },
};
